#ifndef MDTX_USE_RCPPARMADILLO
#define MDTX_USE_RCPPARMADILLO
#endif

#include <RcppArmadillo.h>
using namespace Rcpp;

#include "mdtx-online/indicator/indicator_type_s4_kurtosis.h"
using namespace mdtx::online;

#include "indi_common.h"

using rollkurt_G2_ = indi4<indicator::rollkurt_G2>;

//' Rolling kurtosis G2
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @return List of centre/mean, scale/sd, skewness and kurtosis
//' @export
// [[Rcpp::export(rng = false)]]
List rollkurt_G2(NumericVector x, int period)
{
    auto c = rollkurt_G2_::create_t(period);
    auto ans = rollkurt_G2_::run_t(c, x);
    ans.names() = CharacterVector::create("center", "scale", "skew", "kurt");
    return ans;
}

// [[Rcpp::export(rng = false)]]
SEXP rollkurt_G2_new(int period)
{
    return rollkurt_G2_::create(period);
}

// [[Rcpp::export(rng = false)]]
List rollkurt_G2_run(SEXP ptr, NumericVector x)
{
    auto ans = rollkurt_G2_::run(ptr, x);
    ans.names() = CharacterVector::create("center", "scale", "skew", "kurt");
    return ans;
}

using rollkurt_quantile_ = indi4<indicator::rollkurt_quantile>;

//' Rolling kurtosis moors
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @return List of centre/median, scale/iqr, skewness and kurtosis
//' @export
// [[Rcpp::export(rng = false)]]
List rollkurt_quantile(NumericVector x, int period)
{
    auto c = rollkurt_quantile_::create_t(period);
    auto ans = rollkurt_quantile_::run_t(c, x);
    ans.names() = CharacterVector::create("center", "scale", "skew", "kurt");
    return ans;
}

// [[Rcpp::export(rng = false)]]
SEXP rollkurt_quantile_new(int period)
{
    return rollkurt_quantile_::create(period);
}

// [[Rcpp::export(rng = false)]]
List rollkurt_quantile_run(SEXP ptr, NumericVector x)
{
    auto ans = rollkurt_quantile_::run(ptr, x);
    ans.names() = CharacterVector::create("center", "scale", "skew", "kurt");
    return ans;
}
